package cn.adviceclient;

import cn.adviceclient.event.EventManager;
import cn.adviceclient.features.module.ModuleManager;
import cn.adviceclient.config.ConfigManager;
import de.florianmichael.viamcp.ViaMCP;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.nio.file.Path;
import java.nio.file.Paths;

public class AdviceClient {
    public static final String CLIENT_NAME = "AdviceClient";
    public static final String CLIENT_VERSION = "Beta 1.0";
    public static final Logger LOGGER = LogManager.getLogger(AdviceClient.class);

    private static final Path MAIN_DIRECTORY = Paths.get(System.getProperty("user.home"), ".advice-client");

    public static String windowTitle = CLIENT_NAME + " " + CLIENT_VERSION;

    public static final AdviceClient INSTANCE = new AdviceClient();

    ModuleManager moduleManager;
    EventManager eventManager;


    public void init() {
        LOGGER.info("Initializing AdviceClient...");

        // Initialize the module manager
        ModuleManager.initialize();

        EventManager.initialize();



        LOGGER.info("AdviceClient initialized successfully!");

        eventManager = new EventManager();
    }

    public void shutdown() {
        LOGGER.info("Shutting down AdviceClient...");

        ConfigManager.saveConfigs();
        LOGGER.info("All configurations saved.");
    }

    private void initViaMCP() {
        try {
            ViaMCP.create();
            ViaMCP.INSTANCE.initAsyncSlider();
            LOGGER.info("Load ViaMCP successfully!");
        } catch (Exception e) {
            LOGGER.error("Error:" + e);
        }
    }

    public Path getMainDirectory() {
        return MAIN_DIRECTORY;
    }

}
